<?php
// Copyright (C) 2011 Cassian LUP <cassi.lup@gmail.com>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//SANITIZE ALL ESCAPES
require_once("../../globals.php");
require_once("$srcdir/patient.inc");

$query = '';

$fone = true;

$query = "SELECT * FROM form_pupillometry WHERE form_related IS NULL and pid = $pid order by date";
$res = sqlStatement($query);
$i = 0;

echo "<h2>Registrados por M&eacute;dico";
//if (isset($_REQUEST['medico']))
    echo "<a id='inewform' onclick='open_pupillometry();'class='addIcon css_button css_button_left iframe btnNav fancybox.iframe'  title='Agregar' >";

echo "<i class='icon-plus-sign'></i></a>";
echo "<span id='total_pup' style='float: right; background-color: rgb(228, 228, 228); border-radius: 5px 5px 5px 5px; border-right: 1px solid rgb(204, 204, 204); border-width: 2px 1px 1px; border-style: solid; border-color: -moz-use-text-color rgb(204, 204, 204) rgb(204, 204, 204); -moz-border-top-colors: none; -moz-border-right-colors: none; -moz-border-bottom-colors: none; -moz-border-left-colors: none; border-image: none; padding: 0px 10px;'> " . $i/*sqlNumRows($res)*/ . " </span></h2>";

echo "<ul>";
while ($row = sqlFetchArray($res)){
	/*check revisiones*/
		$fid = $row['id'];
		$query2 = " SELECT * FROM form_pupillometry WHERE (form_related = $fid OR id = $fid) AND pid = $pid ";
		$res2 = sqlStatement($query2);
	/*check revisiones*/
	echo "<li>";
		echo "<span class='title' title=' htmlspecialchars(".$row['date'].", ENT_NOQUOTES); '></span>";
		echo "<a id='iborrar".$row['id']."' class='enlace_borrar iframe_grafico btnNav fancybox.iframe' title='Borrar' href='" . $web_root . "/interface/forms/pupillomtry/delete_form.php?id=".$row['id']."'>";
			echo "<i class='icon-remove'></i>";
		echo "</a>";
		echo "<a id='iform".$row['id']."'  href='" . $web_root . "/forms/pupillometry/index.php?id=".$row['id']."'>";
		echo "- ". xl('pupillometry') . " (" . $row['date'] . ") revisiones: ". sqlNumRows($res2);
		echo "</a>";
	echo "</li>";
	?>
	<script type="text/javascript" language="JavaScript">
	$(document).ready(function() {
		$('#iborrar<?php echo $row['id'] ?>').click(function(e) {
			e.preventDefault();
			parent.$.fancybox({
				href: this.href,
				autoSize: true,
				type: 'iframe',
				helpers: {
					overlay: {
						opacity: 0.3,
						css: {
							'background': 'rgba(255, 254, 254,0.85)'
						}
					} // overlay
				}, // helpers
				afterClose: function() {
					$("#pupillometry").load("<?php echo $web_root; ?>/interface/forms/pupillometry/get_pupillometry.php?medico=1&pid=<?php echo $_REQUEST['pid']; ?>");
				}//afterClose
			}); // fancybox
		}); // click
		
		
	});
	/********************************************************/
	

		
	</script>
<?php
}
echo "</ul>";
?>

